<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
/**
 * Description of XHTML
 *
 * @author spiros
 */
class XHTML {
    private $t;
    function XHTML($title,$menu=NULL) {
        $this->t = new TOOLBOX();
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
        $this->header($title,$menu);
    }

    function header($title,$menu="") {

        $menu = $this->menu($menu);

        echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">
    <head>
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>
        <title>$title</title>
        <style type=\"text/css\">
            @import url(\"./css/css.css\");
        </style>
        <link rel=\"shortcut icon\" href=\"http://eclass.ouc.ac.cy/theme/ouc_formal_white/favicon.ico\" />
        <script type=\"text/javascript\" src=\"./javascript/functions.js\"></script>
    </head>
    <body>
        <table class=\"maintbl\">
        <tr><td width=\"200px\" height=\"40px\"><div align=\"center\"><a href=\"index.php\"><img src=\"./images/logo.png\"/></a></div></td>
        <td><div align=\"center\"><h3>OUC Library - Βιβλιοθήκη ΑΠΚΥ</h3></td></tr>
        <tr><td width=\"200px\" class=\"top\">".$menu."</td><td  style=\"background: white;\" class=\"top\">";

    }

    function menu($menu=NULL) {
        $retval = "<ul>\n";
        if($menu=="") {
            $db = new DB(DBURL, DBUSER, DBPASS, DBNAME);
            $type = $_SESSION['type'];
            //echo "SELECT * FROM menu ORDER by id WHERE type='".$type."'";
            $array = $db->resultasarray("SELECT * FROM menu WHERE type LIKE '%".$type."%' ORDER by id ");
            $t = new TOOLBOX();
            //$t->debug($array);
            for($i=0;$i<count($array);$i++) {
                $retval = $retval."<li><a href=\"".$array[$i][2]."\" alt=\"".$array[$i][3]."\">".$array[$i][1]."</a></li>\n  ";
            }
            $retval = $retval."</ul>\n";
            return $retval;
        }else if(count($menu)>0) {
            foreach ($menu as $key => $val) {
                $retval = $retval."<li><a href=\"".$val."\">".$key."</a></li>\n";
            }
            $retval = $retval."</ul>\n";
            return $retval;
        }


    }

    function img($imgurl) {
        echo "<img src=\"".$imgurl."\" border=0/>\n";
    }

    function footer() {

        echo "</td></tr>\n";
        echo "<tr><td></td><td  style=\"background: white;\" >\n";
        $this->t->tmrtotal();
        echo "</td></tr>\n";
        echo "</body>\n</html>";
    }
}
?>
